package pro.seac.twitter.application.dto;

import static org.apache.commons.lang3.StringUtils.lowerCase;
import pro.seac.twitter.domain.UserAccount;

public class UserAccountDataAssembler implements Assembler<UserAccount, UserAccountData> {

	@Override
	public UserAccountData mapToDto(UserAccount m) {
		UserAccountData account = new UserAccountData();
		account.setId(m.getId());
		account.setCreatedDate(m.getCreatedDate());
		account.setModifiedDate(m.getModifiedDate());
		account.setEmail(m.getEmail());
		account.setName(m.getName());
		account.setUsername(m.getUsername());
		account.setPassword(m.getPassword());
		return account;
	}

	@Override
	public UserAccount mapToModel(UserAccountData d) {
		UserAccount account = new UserAccount();
		account.setId(d.getId());
		account.setCreatedDate(d.getCreatedDate());
		account.setModifiedDate(d.getModifiedDate());
		account.setUsername(lowerCase(d.getUsername()));
		account.setName(d.getName());
		account.setEmail(lowerCase(d.getEmail()));
		account.setPassword(d.getPassword());
		return account;
	}

}
